package com.javenwong.android.engine.script;

public class Task {

	public byte id; // id
	public String name; // �������
	public byte type; // ��������
	public byte level = 0; // ����ȼ�
	public byte targetId; // Ŀ��id
	public byte targetCount = 0; // Ŀ������
	public String desc = ""; // ��������
	public short exp = 0; // ������
	public short money = 0; // �����Ǯ
	public EncouGoods[] encouGoods; // ������Ʒ

	public static final String[] TASK_TYPES = new String[] { "�ռ���Ʒ",
			"ɱ������", "��NPC�Ի�" };

	public String toString() {
		// TODO Auto-generated method stub
		return "����ID��" + id + " --- " + name;
	}

	public String getInfo(Script script) {
		return "����������" + desc + "\n\n" + "����Ҫ��"
				+ getTaskTargetInfo(script) + "\n" + "����ȼ���" + level + "\n"
				+ "�������飺" + exp + "\n" + "�������Ǯ��" + money + "\n"
				+ getEncouGoodsInfo();
	}

	private String getTaskTargetInfo(Script script) {
		switch (type) {
		case 0:
			return "�ռ�\"" + script.getGoodsById(targetId).name + "\" x "
					+ targetCount;
		case 1:
			return "ɱ�� " + targetCount + " ��IDΪ " + targetId + " �ĵ���";
		case 2:
			return "��IDΪ " + targetId + " ��NPC�Ի�";
		}

		return "";
	}

	private String getEncouGoodsInfo() {
		String r = "";

		if (encouGoods.length > 0) {
			r += "������ " + encouGoods.length + " ����Ʒ\n";
			for (int i = 0; i < encouGoods.length; i++) {
				r += "   ��Ʒ" + (i + 1) + "��" + encouGoods[i].goods.name
						+ " x " + encouGoods[i].count + "\n";
			}
		}

		return r;
	}
}
